import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

#1、打开浏览器---驱动管理
ChromeIns = ChromeDriverManager().install()

#创建谷歌浏览器驱动对象
driver = webdriver.Chrome(service=Service(ChromeIns))

driver.get("https://www.baidu.com")

#获取文本信息: text
text = driver.find_element(By.XPATH,'//*[@id="hotsearch-content-wrapper"]/li[7]/a/span[2]').text
print(text)
#验证文本信息是否符合预期
assert text == "全力应对台风桦加沙"

#获取百度一下按钮上的文字
#message = driver.find_element(By.CSS_SELECTOR,"#chat-submit-button").text   #这里获取不到对应的"百度一下"属性值
message = driver.find_element(By.CSS_SELECTOR,"#chat-submit-button").get_attribute("value")
print(message)

driver.quit()






